package com.qolome.excel;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import com.qolome.excel.enums.ExcelOutType;

import lombok.Data;

/**
 * @author Qolome
 */

@Data
public class QolomeWriteExcelBuilder {

    /**
     * 1. 传入模板Excel
     * 2.
     *
     *
     */



    /**
     * 输出工作簿
     */
    private Workbook outWorkbook;

    /**
     * 模板工作簿
     */
    private Workbook templateWorkbook;


    public static QolomeWriteExcelBuilder builder(ExcelOutType excelOutType){

        QolomeWriteExcelBuilder qolomeWriteExcelBuilder = new QolomeWriteExcelBuilder();
        if(ExcelOutType.XLSX==excelOutType){
            qolomeWriteExcelBuilder.outWorkbook = new  XSSFWorkbook();
        }else {
            new HSSFWorkbook();
        }
        return qolomeWriteExcelBuilder;
    }

    public QolomeWriteExcelBuilder template(String templateFile) throws IOException {
        return template(new FileInputStream(templateFile));
    }

    public QolomeWriteExcelBuilder template(InputStream inputStream)
    throws IOException{
        templateWorkbook = new XSSFWorkbook(inputStream);
        return this;
    }


    public void write(OutputStream outputStream){

    }




}
